﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_bkgl_stuinfo : System.Web.UI.Page
{
    DataClassesDataContext db1 = new DataClassesDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            stuInfo();
        }
    }
    private void stuInfo()
    {
        string wbh = Request.QueryString["wbh"].ToString();
        var resNation = from p in db1.proc_GetNation()
                        select p;
        var resPolitics = from p in db1.proc_GetPolitics()
                          select p;
        var result = (from p in db1.proc_GetStuInfoBywbh(wbh)
                      select p).ToList().First();
        Image2.ImageUrl = "~/Student/stuimage/" + result.sidfy + ".jpg";
        Label3.Text = result.sname;
        Label4.Text = result.ssex;
        Label5.Text = result.snation;
        Label6.Text = result.sps;
        string S = result.sbirth;
        if (S != null)
            Label7.Text = S.Substring(0, 4) + "年" + S.Substring(4, 2) + "月" + S.Substring(6, 2) + "日";
        Label8.Text = result.sidfy;
        Label9.Text = result.gkbmh;
        Label10.Text = result.sdept;
        Label11.Text = result.byzy;
        Label12.Text = result.bkgx;
        Label13.Text = result.proName;
        Label14.Text = result.proNum;
        TextBox1.Text = result.getaward;
        TextBox2.Text = result.advantage;
        Label17.Text = result.haddress;
        Label18.Text = result.sphone;
        Label19.Text = result.lxaddress;
        Label20.Text = result.postcode;
        if (result.proflag == 1)
        {
            Panel1.Visible = true;
        }
        else if (result.proflag == 2)
        {
            Panel2.Visible = true;
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("bkgl.aspx");
    }
    protected void Button6_Click(object sender, EventArgs e)
    {
        Response.Redirect("stuimg.aspx?wbh=" + Request.QueryString["wbh"].ToString());
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("stuimg.aspx?wbh=" + Request.QueryString["wbh"].ToString());
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        string wbh = Request.QueryString["wbh"].ToString();
        if ((db1.proc_UpdateStuProFlagBywbh(wbh, 2)) == -1)
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "success", "<script>alert('操作失败，请重试！');</script>");
        }
        else
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "success", "<script>alert('提交成功！');window.location='bkgl.aspx';</script>");
        }
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        string wbh = Request.QueryString["wbh"].ToString();
        if ((db1.proc_UpdateStuProFlagBywbh(wbh, 1)) == -1)
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "success", "<script>alert('操作失败，请重试！');</script>");
        }
        else
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "success", "<script>alert('回退成功！');window.location='bkgl.aspx';</script>");
        }
    }
    protected void Button5_Click(object sender, EventArgs e)
    {

    }
}